package cn.kone.system.service.impl;

import cn.kone.system.domain.Permission;
import cn.kone.system.mapper.PermissionMapper;
import cn.kone.system.query.PermissionQuery;
import cn.kone.system.service.IPermissionService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class PermissionServiceImpl implements IPermissionService {

    @Autowired
    private PermissionMapper permissionMapper;

    /**
     * 查询单个
     * @param id
     * @return
     */
    @Override
    public Permission findOne(Long id) {
        return permissionMapper.findOne(id);
    }

    /**
     * 查询全部
     * @return
     */
    @Override
    public List<Permission> findAll() {
        return permissionMapper.findAll();
    }

    /**
     * 新增单个
     * @param permission
     */
    @Override
    public void addPermission(Permission permission) {
        permissionMapper.addPermission(permission);
    }

    /**
     * 修改单个
     * @param permission
     */
    @Override
    public void updatePermission(Permission permission) {
        permissionMapper.updatePermission(permission);
    }

    /**
     * 删除单个
     * @param id
     */
    @Override
    public void deletePermission(Long id) {
        permissionMapper.deletePermission(id);
    }

    /**
     * 高级查询+分页
     * @param permissionQuery
     * @return
     */
    @Override
    public List<Permission> pageQuery(PermissionQuery permissionQuery) {
        PageHelper.startPage(permissionQuery.getCurrentPage(), permissionQuery.getPageSize());
        return permissionMapper.pageQuery(permissionQuery);
    }

    /**
     * 批量删除
     * @param ids
     */
    @Override
    public void batchDeletePermission(Long[] ids) {
        permissionMapper.batchDeletePermission(ids);
    }
}
